package beans;

import java.io.Serializable;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@Entity
@NamedQueries({
  @NamedQuery(name = "Student.findAll", query = "select o from Student o"),
  @NamedQuery(name = "Student.findByID", query = "select o from Student o where o.id = :studentId")
})
public class Student
  implements Serializable
{
  @Id
  @Column(nullable = false)
  private Long id;
  private String name;
  private Long satisfaction;
  @OneToMany(mappedBy = "student")
  private List<Priority> priorityList;
  @OneToMany(mappedBy = "student", fetch = FetchType.EAGER)
  private List<Studentsubject> studentsubjectList;

  public Student()
  {
  }

  public Student(Long id, String name, Long satisfaction)
  {
    this.id = id;
    this.name = name;
    this.satisfaction = satisfaction;
  }

  public Long getId()
  {
    return id;
  }

  public void setId(Long id)
  {
    this.id = id;
  }

  public String getName()
  {
    return name;
  }

  public void setName(String name)
  {
    this.name = name;
  }

  public Long getSatisfaction()
  {
    return satisfaction;
  }

  public void setSatisfaction(Long satisfaction)
  {
    this.satisfaction = satisfaction;
  }

  public List<Priority> getPriorityList()
  {
    return priorityList;
  }

  public void setPriorityList(List<Priority> priorityList)
  {
    this.priorityList = priorityList;
  }

  public Priority addPriority(Priority priority)
  {
    getPriorityList().add(priority);
    priority.setStudent(this);
    return priority;
  }

  public Priority removePriority(Priority priority)
  {
    getPriorityList().remove(priority);
    priority.setStudent(null);
    return priority;
  }

  public List<Studentsubject> getStudentsubjectList()
  {
    return studentsubjectList;
  }

  public void setStudentsubjectList(List<Studentsubject> studentsubjectList)
  {
    this.studentsubjectList = studentsubjectList;
  }

  public Studentsubject addStudentsubject(Studentsubject studentsubject)
  {
    getStudentsubjectList().add(studentsubject);
    studentsubject.setStudent(this);
    return studentsubject;
  }

  public Studentsubject removeStudentsubject(Studentsubject studentsubject)
  {
    getStudentsubjectList().remove(studentsubject);
    studentsubject.setStudent(null);
    return studentsubject;
  }
}
